/*
** 生成短信模板
*/
function send_tpl(obj){
    var param = get_sms_param(obj);
    if(param){
        param.is_send = 0;
        console.log(param);
        send_sms(param,param.is_send);
    }
}

/*
** 发送短信
*/
function do_send_sms(obj){
    var param = get_sms_param(obj);
    if(param){
        param.is_send = 1;
        console.log(param);
        send_sms(param,param.is_send);
    }
}

/*
** 发送短信
*/
function get_sms_param(obj){
    var name = $("#chakan_user_id").val()
    var mobile = $('#mobile').val();
    if(name.length == 0) {
        layer.alert("请选择查勘人");return false;
    }
    if(mobile.length == 0) {
        layer.alert("请填写查勘人电话");return false;
    }
    var param = {};
    param.id 			= $('#bids').val();
    param.send_type 	= $('.send_type:radio:checked').val();
    param.chakan_ren 	= name;
    param.chakan_mobile = mobile;
    return param;
}
/*
** 发送短信
*/
function send_sms(param,is_send)
{
    $.post("sms/sms/public_send_sms",param,function(res){
        if(res.code != 1){
            layer.msg(res.msg,{icon:2});return false;
        }
        if(is_send == 0){
            $('#sms_moban').val(res.msg);
            return false;
        }
        layer.msg("发送成功",{icon:1});
    },'json');
}